home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_iicache.asp < prev    next >
Encoding:
Text File  |  1999-06-03  |  5.9 KB  |  249 lines

  1. <%@ LANGUAGE = VBScript %>
  2. <% 'Option Explicit %>
  3. <!-- #include file="directives.inc" -->
  4.  
  5. <!--#include file="iicache.str"-->
  6. <!--#include file="iiaspstr.inc"-->
  7.  
  8. <% 
  9. 'Call this page with a query string of ?sname=machinename
  10. 'example: http://larad01/iis/iicnct.asp?sname=larad01
  11.  
  12. On Error Resume Next 
  13.  
  14. Dim path, sname, scripttimeout, FileSystem, quote, errd, currentADsObj, lastobj
  15. Dim newid, topid, firstid, currentid, numNewItems
  16.  
  17.  
  18. 'This script can take a _long_ time to execute,
  19. 'as we may be dealing with thousands of items
  20. 'to add to our JScript object.
  21. 'save our current script timeout value & set to a much longer value...
  22.  
  23. scripttimeout = Server.ScriptTimeOut
  24. Server.ScriptTimeOut = 2000
  25.  
  26. Set FileSystem=CreateObject("Scripting.FileSystemObject")
  27.  
  28. path=Request.QueryString("sname")
  29.  
  30. quote=chr(34)
  31. errd=False
  32. if (len(path) <> 0) then
  33.     Set currentADsObj=GetObject(path) 
  34.     if err <> 0 then
  35.         errd=True
  36.     end if 
  37. end if 
  38.  
  39. lastobj = ""
  40.  
  41. %>
  42.  
  43.  
  44.  
  45. <HTML>
  46. <HEAD>
  47. <SCRIPT LANGUAGE="JavaScript">
  48.  
  49. var theList=top.title.nodeList;
  50.  
  51. <% 
  52.  
  53. if errd=0 then 
  54.     
  55.  
  56.     newid=Request.QueryString("Nextid")
  57.     
  58.     firstid=newid
  59.     if firstid="" then
  60.         firstid=0
  61.     end if 
  62.     
  63.     currentid=Request.QueryString("currentid")
  64.     if currentid="" then
  65.         currentid=firstid
  66.         newid=newid + 1
  67.     end if 
  68.     
  69.     numNewItems=0
  70.     
  71.     if (len(path) <> 0) then
  72.     
  73.          %>theList[<%= currentid %>].isCached=true;<% 
  74.          %>theList[<%= currentid %>].open=true;<% 
  75.         
  76.         addObject currentADsObj,currentid,"vdir"
  77.  
  78.         if Instr(currentADsObj.KeyType, "VirtualDir") <> 0 then 
  79.             addDirs currentADsObj.Path, currentADsObj.ADsPath, currentid, "dir"
  80.         end if                
  81.     end if
  82.     Server.ScriptTimeOut = scripttimeout
  83. end if
  84.  
  85. Sub addObject(Container, parentid, vtype)
  86.  
  87.     On Error Resume Next 
  88.     Dim thisname, isApp, thisid, thisstate
  89.     Dim approot, thisroot
  90.     
  91.     if err.number <> 0 then
  92.         errd = true
  93.     else
  94.         For Each Child In Container
  95.             if Instr(Child.KeyType, "VirtualDir") <> 0 then    
  96.                 thisid=newid
  97.                 thisname=Child.Name
  98.                 thisstate=2
  99.                 isApp = False
  100.                 approot=LCase(Child.AppRoot)
  101.                 if len(approot) <> 0 then
  102.                     thisroot = LCase(Child.ADsPath)
  103.                     approot = Mid(approot,Instr(approot,"w3svc/")+1)
  104.                     thisroot = Mid(thisroot,Instr(thisroot,"w3svc/")+1)
  105.     
  106.                     if Right(approot,1) = "/" then
  107.                         thisroot = thisroot & "/"
  108.                     end if        
  109.                     
  110.                     if thisroot=approot then
  111.                         isApp = True
  112.                     end if
  113.                 end if                        
  114.                 if UCase(thisname) <> "ROOT" then 
  115.     
  116.                     SetJscriptObj thisname, Child.ADsPath, parentid, vtype, thisstate, Child.Path, isApp
  117.                     numNewItems=numNewItems + 1
  118.     
  119.                     addObject Child, thisid, "vdir"
  120.                     addDirs Child.Path, Child.ADsPath, thisid, "dir"                
  121.                 else        
  122.                     addObject Child, parentid, "vdir"
  123.                     addDirs Child.Path, Child.ADsPath, parentid, "dir"
  124.                 end if
  125.             end if 
  126.         Next
  127.     end if
  128.         
  129. End Sub
  130.  
  131. Sub addDirs(path, adspath, parentid, vtype)
  132.  
  133. Dim thisid, thisname, thisstate, thisadspath, i, f
  134.  
  135. if Instr(UCase(adspath),"W3SVC") <> 0  then     
  136.     if path <> "" then 
  137.         if Left(path,2) <> "\\" then
  138.             if FileSystem.FolderExists(path) then    
  139.                  Set f=FileSystem.GetFolder(path)
  140.                  For Each i In f.SubFolders
  141.                  thisid=newid
  142.                  thisstate=2
  143.                   thisadspath = adspath & "/" & i.Name
  144.                      SetJscriptObj i.Name,thisadspath, parentid, vtype, thisstate,i,False
  145.                   numNewItems=numNewItems + 1
  146.                   if err=0 then
  147.                      addDirs i, thisadspath, thisid, "dir"             
  148.                  end if         
  149.                  Next
  150.             end if
  151.         end if    
  152.     end if
  153. end if
  154. End Sub
  155.  
  156. Sub SetJscriptObj(caption, path, parentid,vtype,state, fspath,isApp)
  157.      %>     
  158.     theList[<%= newid %>]=theList[<%= parentid %>].addNode(new top.title.listObj(<%= newid %>,"<%= sJSLiteral(caption) %>","<%= sJSLiteral(path) %>","<%= vtype %>",<%= state %>));
  159.     theList[<%= parentid %>].isCached=true;
  160.     theList[<%= newid %>].isCached=true;
  161.     <% if isApp then %>
  162.         theList[<%= newid %>].icon = top.title.Global.imagedir + "app";
  163.         theList[<%= newid %>].isApp = true;
  164.     <% end if %>
  165.     theList[<%= newid %>].fspath="<%= replace(fspath,"\","\\") %>";
  166.     <% 
  167.     newid=newid + 1
  168.     
  169. End Sub
  170.  
  171.  
  172. ' we need to insert the whole group into the correct place In the array.
  173. ' since we Set the first entry (machine) to the exisitng place In the array,
  174. ' the Next level In the hierarchy (vservers) will be pointing to the correct
  175. ' parent ids. However, the following level (vdirs, and below) will be pointing
  176. ' to the parent ids as they existed at the bottom of the array, before the
  177. ' move, and will need to be adjusted.
  178. %>
  179.  
  180. <% if errd=0 then %>
  181.  
  182.     gVars=top.title.Global;
  183.     var item=<%= firstid %>;
  184.     currentid=<%= currentid %>;
  185.     if (currentid !=item){
  186.  
  187.         x=currentid + 1;
  188.     
  189.         //correct the id on the "new" objects
  190.         for (var i=item; i < theList.length; i++) {
  191.                 theList[i].id=x;            
  192.                 if (theList[i].parent !=currentid){
  193.                     theList[i].parent=theList[i].parent - (item - (currentid + 1));
  194.                 }        
  195.                 x++;
  196.         }
  197.     
  198.         //move the following records "down" the array
  199.         for (var i=currentid + 1; i < item;i++){
  200.  
  201.             theList[i].id=theList[i].id + <%= numNewItems %>;
  202.             if (theList[i].parent >currentid){
  203.                     theList[i].parent=theList[i].parent + <%= numNewItems %>;
  204.             }    
  205.         }
  206.     
  207.  
  208.     }
  209.  
  210.  
  211.     //and re-sort.
  212.     theList[0].sortList();
  213.     theList[0].markTerms();
  214.  
  215.  
  216.     if (theList.length==1){
  217.         gVars.selId=0;
  218.         theList[0].selected=true;
  219.     }
  220.     else{
  221.         theList[gVars.selId].selected=false;
  222.         gVars.selId=<%= currentid %>;
  223.         theList[<%= currentid %>].selected=true;
  224.     }
  225.  
  226.     top.body.list.location.href="iisrvls.asp"
  227.  
  228. <% else %>
  229.     alert("<%= L_CNCTERR_TEXT %> (<%= err %>)");
  230. <% end if %>
  231.  
  232. top.body.iisstatus.location="iistat.asp"
  233.  
  234. </SCRIPT>
  235.  
  236. <% if err <> 0 then %>
  237. <% Response.write "err: " & err.description %><BR>
  238. <% Response.write "currentcontainer: " & currentADsObj.ADsPath %><BR>
  239. <% Response.write "                  " & currentADsObj.KeyType %><BR>
  240. <% Response.write "Err Container:" & lastobj %><BR>
  241. <% end if %>
  242.  
  243. </HEAD>
  244.  
  245. <BODY>
  246. </BODY>
  247. </HTML>
  248.  
  249.